package com.qingchi.server.openData;

import com.qingchi.base.common.ConfigMapRefreshService;
import com.qingchi.base.common.ViolationKeywordsService;
import com.qingchi.base.config.redis.RedisUtil;
import com.qingchi.base.manage.TalkManage;
import com.qingchi.base.redis.DistrictRedis;
import com.qingchi.base.redis.TagRedis;
import com.qingchi.base.repository.config.HomeSwiperRepository;
import com.qingchi.base.repository.district.DistrictRepository;
import com.qingchi.base.repository.log.FrontErrorLogRepository;
import com.qingchi.base.repository.openData.DevAccountRepository;
import com.qingchi.base.repository.openData.UnionIdRepository;
import com.qingchi.base.repository.tag.TagRepository;
import com.qingchi.base.repository.talk.TalkRepository;
import com.qingchi.base.service.ChatUserService;
import com.qingchi.base.service.LoginService;
import com.qingchi.base.service.TagService;
import com.qingchi.base.service.TalkQueryService;
import com.qingchi.base.store.TagStoreUtils;
import com.qingchi.base.store.TalkQueryStore;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("talk")
public class OpenTalkQueryController {
    public final Logger logger = LoggerFactory.getLogger(getClass());
    @Resource
    private UnionIdRepository contentUnionIdRepository;

    @Resource
    private TagRepository tagRepository;
    @Resource
    private TagStoreUtils tagQueryRepository;
    @Resource
    private TagRedis tagRedis;
    @Resource
    private DistrictRepository districtRepository;
    @Resource
    private ViolationKeywordsService violationKeywordsService;
    @Resource
    private ConfigMapRefreshService configMapRefreshService;
    @Resource
    private RedisUtil redisUtil;
    @Resource
    private ChatUserService chatUserService;
    @Resource
    private HomeSwiperRepository homeSwiperRepository;
    @Resource
    private TagService tagService;

    @Resource
    private DistrictRedis districtRedis;
    @Resource
    private TalkQueryService talkQueryService;
    @Resource
    private LoginService loginService;
    @Resource
    private FrontErrorLogRepository frontErrorLogRepository;
    @Resource
    private TalkRepository talkRepository;
    @Resource
    private TalkQueryStore talkQueryStore;
    @Resource
    private TalkManage talkManage;


    @Resource
    private DevAccountRepository devAccountRepository;


    /*@PostMapping("queryAppInitDataReady")
    public ResultVO<?> queryAppInitDataReady(UserDO user, Integer devId, Long devNum) {
        AppInitDataVO appInitData;
        if (user != null) {
            appInitData = loginService.getUserInitData(user, false, devId, devNum);
        } else {
            appInitData = new AppInitDataVO();
            //chats
            List<ChatVO> chatVOs = chatUserService.getChats();
            appInitData.setChats(chatVOs);
        }
        //tags
        //前台搜索，和新增tag搜索时展示使用
        appInitData.setTags(tagRedis.getHotTags(GenderType.all));
        //tagTypes
        appInitData.setTagTypes(tagRedis.getHotTagTypes(GenderType.all));
        //reportTypes
        appInitData.setReportTypes(ViolateType.frontShowReportTypes);
        //districts
        List<DistrictVO> districtVOS = districtRedis.getHotDistricts();
        appInitData.setDistricts(districtVOS);
        //onlineUsersCount
        appInitData.setOnlineUsersCount(WebsocketServer.getOnlineCount());
        return new ResultVO<>(appInitData);

    }*/

}
//查询最多两条置顶内容
//为首次查询
//只有首页才显示置顶内容？(TalkTabType.home_type.equals(talkType) || (HomeType.home_name.equals(talkType))) &&
            /*if ((talkIds.size() == 1 && talkIds.get(0).equals(0))) {
                    talkDOS = talkRepository.findTop2ByStatusAndGlobalTopGreaterThanOrderByGlobalTopDesc(ContentStatus.otherCanSeeContentStatus, talkIds, CommonStatus.initNum);
                    talkIds.addAll(talkDOS.stream().map(TalkDO::getId).collect(Collectors.toList()));
                    }*/

//如果传进来的时是空的，则默认赋值[0]，因为sql in 需要有值